package Test1.Thermometry;

import Test1.HCNetSDK;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;

/**
 * Created by panting6 on 2021/6/29.
 */
public class BasicParam {
    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    public void basicParam (int lUserID, int iChannelNum)
    {
        IntByReference pchannel = new IntByReference(iChannelNum);
        Pointer pChannelNum = pchannel.getPointer();

        HCNetSDK.NET_DVR_STD_CONFIG lpConfigParam3622 = new HCNetSDK.NET_DVR_STD_CONFIG();
        HCNetSDK.NET_DVR_THERMOMETRY_BASICPARAM lpTherBasicParam3622 = new HCNetSDK.NET_DVR_THERMOMETRY_BASICPARAM();
        lpConfigParam3622.lpCondBuffer = pChannelNum;
        lpConfigParam3622.dwCondSize = 4;
        HCNetSDK.BYTE_ARRAY m_szStatusBuf = new HCNetSDK.BYTE_ARRAY(4096 * 4);
        lpConfigParam3622.lpStatusBuffer = m_szStatusBuf.getPointer();
        lpConfigParam3622.dwStatusSize = 4096 * 4;
        lpTherBasicParam3622.dwSize = lpTherBasicParam3622.size();
        lpTherBasicParam3622.byEnabled = 1;
        lpTherBasicParam3622.byStreamOverlay = 1;
        lpTherBasicParam3622.byPictureOverlay = 1;
        lpTherBasicParam3622.byThermometryRange = 1;
        lpTherBasicParam3622.byThermometryUnit =0;
        lpTherBasicParam3622.byShowTempStripEnable =1;
        lpTherBasicParam3622.fEmissivity = (float)0.98;
        lpTherBasicParam3622.byDistanceUnit = 2;
        lpTherBasicParam3622.wDistance = 1000;
        lpTherBasicParam3622.byDisplayMaxTemperatureEnabled = 1;
        lpTherBasicParam3622.byDisplayMinTemperatureEnabled = 1;
        lpTherBasicParam3622.byDisplayAverageTemperatureEnabled = 1;
        lpTherBasicParam3622.write();
        lpConfigParam3622.lpInBuffer = lpTherBasicParam3622.getPointer();
        lpConfigParam3622.dwInSize = lpTherBasicParam3622.dwSize;
        lpConfigParam3622.write();
        if(!hCNetSDK.NET_DVR_SetSTDConfig(lUserID,3622,lpConfigParam3622))
        {
            System.out.println( "设置测温基本参数失败，错误号：" + hCNetSDK.NET_DVR_GetLastError());
        }
        else{
            System.out.println( "设置测温基本参数成功");
        }


        HCNetSDK.NET_DVR_STD_CONFIG lpConfigParam3621 = new HCNetSDK.NET_DVR_STD_CONFIG();
        HCNetSDK.NET_DVR_THERMOMETRY_BASICPARAM lpTherBasicParam = new HCNetSDK.NET_DVR_THERMOMETRY_BASICPARAM();

        lpConfigParam3621.lpCondBuffer = pChannelNum;
        lpConfigParam3621.dwCondSize = 4;
        lpConfigParam3621.lpInBuffer = null;
        lpConfigParam3621.dwInSize = 0;
        lpConfigParam3621.lpOutBuffer = lpTherBasicParam.getPointer();
        lpConfigParam3621.dwOutSize = lpTherBasicParam.size();
        lpConfigParam3621.write();
        lpTherBasicParam.write();

        if(!hCNetSDK.NET_DVR_GetSTDConfig(lUserID,3621,lpConfigParam3621))
        {
            System.out.println( "获取测温基本参数失败，错误号：" + hCNetSDK.NET_DVR_GetLastError());
        }
        else{
            lpTherBasicParam.read();
            System.out.println("获取测温基本参数成功，测温使能：" + lpTherBasicParam.byEnabled + " 码流叠加温度信息：" + lpTherBasicParam.byStreamOverlay
                    + " 抓图叠加温度信息：" + lpTherBasicParam.byPictureOverlay + " 测温范围：" + lpTherBasicParam.byThermometryRange
                    + " 测温单位：" + lpTherBasicParam.byThermometryUnit + " 显示温度条：" + lpTherBasicParam.byShowTempStripEnable
                    + " 发射率：" + lpTherBasicParam.fEmissivity + " 距离单位：" + lpTherBasicParam.byDistanceUnit + " 距离：" + lpTherBasicParam.wDistance
                    + " 特殊测温点显示：" + lpTherBasicParam.bySpecialPointThermType + " 最高温显示：" + lpTherBasicParam.byDisplayMaxTemperatureEnabled
                    + " 最低温显示：" + lpTherBasicParam.byDisplayMinTemperatureEnabled + " 平均温显示：" + lpTherBasicParam.byDisplayAverageTemperatureEnabled);
        }
    }
}
